﻿# The entry should be named in the same way that the elective succession law is named to define it's voter's logic.
# Root scope - Elector, the character voting in the election.
# scope:candidate scope - Candidate, Character considered for the title.
# scope:title scope - Title, The title the nomination is for.
# scope:holder scope - Ruler, The ruler currently holding the title.
# scope:holder_candidate scope - Favored Candidate, The title owner's candidate.
# The voter will vote for the top score candidate calculated from this script.

saxon_elective = { #Witenagemot
	elector_vote_strength = {
		base = 1
		modifier = { #Imperial Dignity
			desc = tooltip_feudal_vote_strength_emperor_tier
			add = 3
			highest_held_title_tier = 5
		}
		modifier = { #Royal Dignity
			desc = tooltip_feudal_vote_strength_king_tier
			add = 2
			OR = {
				highest_held_title_tier = 4
				AND = {
					highest_held_title_tier = 3
					this = scope:holder
				}
			}
		}
		modifier = { #Princely Dignity
			desc = tooltip_feudal_vote_strength_duke_tier
			add = 1
			highest_held_title_tier = 3
			NOT = {
				this = scope:holder
			}
		}
		modifier = { #Powerful Vassal
			desc = tooltip_feudal_vote_strength_powerful_vassal
			add = {
				value = 1
				if = { #Additional point if the vassal is more powerful than the current ruler
					limit = {
						max_military_strength > scope:holder.max_military_strength
					}
					add = 1
				}
			}
			NOT = { this = scope:holder }
			is_powerful_vassal = yes
			liege = scope:holder
		}
		modifier = { #Regent Influence
			desc = tooltip_feudal_vote_strength_is_diarch
			add = 1
			is_diarch_of_target = scope:holder
		}
	}
	
	electors = {
		add = holder
		add = {
			type = title_dejure_vassals
			limit = {
				is_vassal_of = scope:holder #All direct de jure vassals, no matter the tier.
				is_adult = yes
				NOT = { has_trait = incapable }
			}
		}
		add = {
			type = holder_direct_vassals
			limit = {
				scope:holder = {
					highest_held_title_tier = 3
				}
				is_adult = yes
				NOT = { has_trait = incapable }
			}
		}
		#TODO_CD:If landless electors become supported by Code, add the ruler's close family members (adults only) to the list of viable Electors.
	}

	candidate_score = {
		base = 0
		######################	Elector self-voting pattern	##########################
		elector_self_voting_pattern_feudal_elective_modifier = yes

		##########################	Holder voting pattern	##########################
		holder_voting_pattern_feudal_elective_modifier = yes

		##########################	Elector voting patterns (circumstances)	##########################
		elector_voting_pattern_circumstances_feudal_elective_modifier = yes
		elector_voting_pattern_circumstances_saxon_elective_modifier = yes

		##########################	Elector voting patterns (prestige/piety)	##########################
		elector_voting_pattern_prestige_piety_feudal_elective_modifier = yes

		##########################	Elector voting patterns (traits)	##########################
		elector_voting_pattern_traits_feudal_elective_modifier = yes

		##########################	Elector voting patterns (opinion)	##########################
		elector_voting_pattern_opinion_feudal_elective_modifier = yes
	}
	
	#scope:candidate = Candidate, scope:title = Title, scope:holder_candidate = Candidate currently selected by ruler.
	candidates = {
		add = {
			type = title_dejure_vassals
			limit = {
				is_vassal_of = scope:holder #Only Powerful, direct, de jure vassals are potential candidates.
				is_powerful_vassal = yes
				feudal_elective_potential_landed_candidate_trigger = yes
			}
		}
		add = {
			type = title_claimants
			limit = {
				feudal_elective_potential_landless_claimant_candidate_trigger = yes
			}
		}
		add = {
			type = holder_close_or_extended_family
			limit = {
				is_child_of = scope:holder #In Saxon Elective filter only the children of the current holder.
				feudal_elective_potential_landless_dynastic_candidate_trigger = yes
			}
		}
	}
}
